#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
int n,l,r;
int ans;
int main(){
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	scanf("%d%d%d",&n,&l,&r);
	if(r-l>=n-1)ans=n-1;
	else{
		l%=n;
		r%=n;
		if(l>r)ans=n-1;
		else ans=r;
	}
	printf("%d",ans);
	fclose(stdin);
	fclose(stdout);
	return 0;
}
